﻿using my_webapi_demo.Common;

namespace my_webapi_demo.Tast
{
    public class MyTask01 : HuaskyTask
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (true)
            {
                LoggerHelper.Info("哈哈: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                await Task.Delay(1000);
            }
        }
    }

    public class MyTask02 : HuaskyTask
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var num = 0;
            var timer = new PeriodicTimer(TimeSpan.FromSeconds(5));
            while (await timer.WaitForNextTickAsync(stoppingToken))
            {
                LoggerHelper.Info("叫号: " + num++);
            }
        }
    }
}
